package com.gxa.hotel.admin.filter;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.shiro.web.filter.authc.UserFilter;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class LoginFilter extends UserFilter {

    @Override
    protected void redirectToLogin(ServletRequest request, ServletResponse response) throws IOException {
        response.setContentType("application/json;charset=utf-8");
         Map map = new HashMap();
         map.put("code","500");
         map.put("msg","未登录");
         ObjectMapper objectMapper = new ObjectMapper();
         String string = objectMapper.writeValueAsString(map);
         response.getWriter().write(string);
    }
}
